/**
 * 
 */

//求1~100的奇数和？
var sum = 0;
for (var i = 1; i <= 100; i++) {
    if (i % 2 == 1) {
        sum = sum + i;
        // document.write(sum+'<br/>');
    }
}
document.write('求1~100的奇数和 ：' + sum + '<hr/>');
//求1~100的偶数之和？
sum = 0;
for (var i = 1; i <= 100; i++) {
    if (i % 2 == 0) {
        sum += i
    }
}
document.write('求1~100的偶数之和:    ' + sum + '<hr/>');

//倒置的99乘法表
document.write("<table border='1' cellpadding='0' cellspacing='0' bgcolor='aqua' width='80%'>");
for (var i = 9; i >= 1; i--) {
    document.write('<tr>');
    for (var j = 1; j <= i; j++) {
        document.write('<td>' + i + 'X' + j + '=' + (i * j) + '</td>');
    }
    document.write('</tr>');
}
document.write("</table>")

//通过for循环实现百元买百鸡的题
//公鸡5元，母鸡3元，小鸡一元3只
for (var x = 0; x <= 20; x++) {
    for (var y = 0; y <= 33; y++) {
        for (var z = 0; z <= 100; z++) {
            if ((x + y + z == 100) && (5 * x + 3 * y + z / 3 == 100)) {
                document.write('公鸡' + x + '母鸡' + y + '小鸡' + z + '<hr/>');
            }
        }
    }
}
document.write('<hr/>')
for (var x = 0; x <= 20; x++) {
    for (var y = 0; y <= 33; y++) {
        var z;
        z = 100 - x - y;
        if ((z % 3 == 0) && (5 * x + 3 * y + z / 3 == 100)) {
            document.write('公鸡' + x + '母鸡' + y + '小鸡' + z + '<hr/>');
        }
    }
}